package PalindromicStrings;

import java.sql.SQLOutput;
import java.util.Locale;

public class palindromic {

    public static void main(String[] args) {
        System.out.println(isPalindromic("AA,BB,DD,EE,RR,TT,,,t,p,,,TTRREEDDBBAA,,"));
    }

    //判断是否为回文字符串
    public static boolean isConform(char c) {
        if ('a' < c && c < 'z' || '0' < c && c < '9') {
            return true;
        }
        return false;
    }

    public static boolean isPalindromic(String str) {
        str = str.toLowerCase();
        int left = 0;
        int right = str.length() - 1;
        while (left < right) {

            while (left < right && !isConform(str.charAt(left))) {
                left++;
            }

            while (left < right && !isConform(str.charAt(right))) {
                right--;
            }


            if (str.charAt(left) != str.charAt(right)) {
                return false;
            }
            left++;
            right--;
        }
        return true;
    }
}
